<nav class="navbar navbar-expand-lg bg-body-tertiary shadow-sm indexNavbar">
    <div class="container">
        <a class="navbar-brand d-flex justify-content-start align-items-center" href="{{route('index')}}">
            <img class="d-inline-block align-text-center me-2" width="30" src="{{url('images/logo/flarum.webp')}}" alt="logo">
            PCB.IO
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link {{active_class(if_route('topics.index'))}}" aria-current="page" href="{{route('topics.index')}}">全部</a>
                </li>
                @foreach($categories as $category)
                    <li class="nav-item">
                        <a class="nav-link {{isset($category->current_page_active)?'active text-bg-secondary':''}}" href="{{route('categories.show',$category->id)}}">{{$category->name}}</a>
                    </li>
                @endforeach


            </ul>
            <ul class="navbar-nav">
                @guest()
                <li class="nav-item">
                    <a class="nav-link " href="{{url('login')}}">登录</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{url('register')}}">注册</a>
                </li>
                @else
                    {{--发帖--}}
                    <li class="d-flex align-items-center me-4">
                        <a title="发帖" href="{{route('topics.create')}}" class=" fa-duotone fa-solid fa-pen-to-square text-decoration-none"></a>
                    </li>
                    {{--消息--}}
                    <li class="d-flex align-items-center me-4">
                            @if(Auth::user()->notification_count)
                                <a title="查看消息" href="{{route('notifications.index')}}" class="d-flex justify-content-center align-items-center text-decoration-none">
                                    <i class="fa-solid fa-envelope-open-text"></i>
                                <span class="badge bg-danger ms-1 ">{{Auth::user()->notification_count}}</span>
                                </a>
                                @else
                                <a title="查看消息" href="{{route('notifications.index')}}" class="d-flex justify-content-center align-items-center text-decoration-none">
                                    <i class="fa-solid fa-envelope-open"></i>
                                </a>
                            @endif
                    </li>

                    {{--个人信息--}}
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <img class="img-thumbnail" src="{{get_user_avatar(Auth::user()->avatar)}}" alt="avatar" width="40">
                            {{Auth::user()->name}}
                        </a>
                        <ul class="dropdown-menu">
                            <li class="text-center"><a class="dropdown-item" href="{{route('users.show',Auth::id())}}">
                                    <i class="fa-solid fa-user"></i>
                                    个人中心
                                </a>
                            </li>
                            <li class="text-center">
                                <a class="dropdown-item" href="{{route('users.edit',Auth::id())}}">
                                    <i class="fa-solid fa-pen"></i>
                                    编辑资料
                                </a>
                            </li>
                            <li><hr class="dropdown-divider"></li>
                            <li class="text-center">
                                <form action="{{route('logout')}}" method="post">
                                    @csrf
                                    <button class="btn btn-sm btn-danger" type="submit">
                                        <i class="fa-solid fa-right-from-bracket"></i>
                                        退出登录
                                    </button>
                                </form>
                            </li>
                        </ul>
                    </li>
                @endguest
            </ul>
        </div>
    </div>
</nav>
